package com.ysh.spring;

import com.ysh.spring.pojo.Address;
import com.ysh.spring.pojo.User;
import com.ysh.spring.service.UserService;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * 袁胜虎 on 2022/8/26 21:27
 */
public class test {

    @Test
    public void testDi() {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        UserService service = context.getBean(UserService.class);
        System.err.println(service);
        service = context.getBean(UserService.class);
        System.err.println(service);
        service.addUser();
        context.close();
    }
    @Test
    public void testDi2() {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        User user = context.getBean(User.class);
        System.err.println(user);
        context.close();
    }

    @Test
    public void testDi3() {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        Address address = context.getBean(Address.class);
        System.err.println(address);
    }
}
